package com.ysh.smartplatform.mapper;

import com.ysh.smartplatform.pojo.SysCategory;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 袁胜虎 on 2022/9/6 21:29
 */
public interface CategoryMapper {
    @Insert("INSERT INTO sys_category (category_name,tx_command,rx_command,command_name,create_by) VALUES (#{categoryName},#{txCommand},#{rxCommand},#{commandName},#{createBy})")
    void addCategory(SysCategory category);

    @Select("SELECT * FROM sys_category WHERE category_name =#{categoryName}")
    SysCategory findByCategoryName(String categoryName);

    @Update("update sys_category set category_name=#{categoryName},tx_command=#{txCommand},rx_command=#{rxCommand},command_name=#{commandName},status=#{status},update_by=#{updateBy} WHERE c_id =#{cId}")
    void updateCategory(SysCategory category);

    @Select("select * from sys_category")
    List<SysCategory> findAllCategories();

    @Delete("delete from sys_category where c_id = #{cId}")
    void deleteById(Long cId);

    @Select("select c_id,category_name,tx_command ,command_name  from sys_category where c_id = #{cId})")
    void findByCommend(Long cId);

}
